package ioio.examples.simple;
import pkg496_spu.*;

import android.app.Activity;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;

class audioClass extends Activity
{   private SoundPool soundPool;
    int[] soundID = new int[3];

    boolean loaded;
    
    @Override
	public void onCreate(Bundle savedInstanceState) {

	this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
	// Load the sound
	 soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
	/*Probably don't need this here
	 soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
		public void onLoadComplete(SoundPool soundPool, int sampleId,
				int status) {
			boolean loaded = true;
		}
	}); */
	soundID[0] = soundPool.load(this, R.raw.sound1, 1);
	soundID[1] = soundPool.load(this, R.raw.sound2, 1);
	soundID[2] = soundPool.load(this, R.raw.sound3, 1);
    }
    public void play(int id)
    {
    	AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);

    	float actualVolume = (float) audioManager
		.getStreamVolume(AudioManager.STREAM_MUSIC);
float maxVolume = (float) audioManager
		.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
		float volume = actualVolume/maxVolume;
		if (loaded)
    	soundPool.play(soundID[id],volume,volume,1,0,1f);
		loaded = false;
    }
};